package com.blog.wu.myblog.service;

import com.blog.wu.myblog.base.BaseCrudService;
import com.blog.wu.myblog.dao.ArticleInfoMapper;
import com.blog.wu.myblog.dao.CategoryInfoMapper;
import com.blog.wu.myblog.entity.CategoryInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author wuyanshen
 * @Date 2018-10-16 上午11:03
 * @Discription 栏目业务类
 */
@Service
public class CategoryInfoService extends BaseCrudService<CategoryInfoMapper, CategoryInfo> {

    @Autowired
    private ArticleInfoMapper articleInfoMapper;

    @Transactional(readOnly = false)
    public boolean deleteAll(CategoryInfo categoryInfo) {
        int flag1 = articleInfoMapper.deleteByCateId(categoryInfo.getId());
        int flag2 = super.dao.delete(categoryInfo);
        if (flag1 > 0 && flag2 > 0) {
            return true;
        }
        return false;
    }
}
